<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<base th:href="@{/}">
<meta charset="utf-8">
<title>用户修改</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="static/layui/css/layui.css" media="all" />
<style type="text/css">
.layui-form-item .layui-inline {
	width: 33.333%;
	float: left;
	margin-right: 0;
}

@media ( max-width :1240px) {
	.layui-form-item .layui-inline {
		width: 100%;
		float: none;
	}
}
</style>
</head>
<body>
	<form class="layui-form" action="">
		<div class="layui-form-item" style="margin-top: 15px;">
			<label class="layui-form-label">原密码</label>
			<div class="layui-input-inline">
				<input id="oldpwd" name="oldpwd" class="layui-input" type="password" placeholder="请输入原密码" >
			</div>
		</div>
		<div class="layui-form-item" style="margin-top: 15px;">
			<label class="layui-form-label">新密码</label>
			<div class="layui-input-inline">
				<input id="newpwd" name="newpwd" class="layui-input" type="password" placeholder="请输入新密码" >
			</div>
		</div>
		<div class="layui-form-item" style="margin-top: 15px;">
			<label class="layui-form-label">确认密码</label>
			<div class="layui-input-inline">
				<input id="newpwd2" name="newpwd2" class="layui-input" type="password" placeholder="请再次输入新密码" >
			</div>
		</div>
		<div class="layui-form-item" style="margin-top: 15px;">
			<label class="layui-form-label"></label>
			<input class="layui-btn" type="button" id="submit" value="确定" />
		</div>
	</form>
    
	<script type="text/javascript" src="static/layui/layui.js"></script>
	<script type="text/javascript">
		layui.use(['form','layer','jquery','table','laydate','upload'],function(){
		    var layer = layui.layer,
		        $ = layui.jquery;
		    
			$("#submit").click(function(){
				var oldpwd = $.trim($("#oldpwd").val());
				var newpwd = $.trim($("#newpwd").val());
				var newpwd2 = $.trim($("#newpwd2").val());
				if(oldpwd == "" || newpwd == "" || newpwd2 == ""){
					top.layer.msg("不能为空");
					return;
				}
				if(newpwd != newpwd2){
					top.layer.msg("新密码和确认密码不一致");
					return;
				}
				if(newpwd.length <6){
					top.layer.msg("新密码长度必须大于6");
					return;
				}
				$.post("/user/updatePwd",{oldpwd:oldpwd,newpwd:newpwd},function(data){
					if(data.code == '500'){
						top.layer.msg(data.msg);
					}else{
						top.layer.msg("修改成功");
						$("#oldpwd").val("");
						$("#newpwd").val("");
						$("#newpwd2").val("");
						top.window.location.href="/loginOut";
					}
				});
			});
		})
	</script>
</body>
</html>